package interview.itoa;

public class I2A {
	public String itoa(int num) {
		StringBuilder sb = new StringBuilder();
		while(num > 0) {
			sb.append(num % 10);
			num /= 10;
		}

		char[] array = new char[sb.length()];
		sb.getChars(0, sb.length(), array, 0);

		int head = 0;
		int tail = sb.length() - 1;
		char temp;
		while(head < tail) {
			temp = array[head];
			array[head] = array[tail];
			array[tail] = temp;
			head++;
			tail--;
		}

		return new String(array);
	}
}
